/* 
 * File:   VistaNivel.h
 * Author: agu
 *
 * Created on 7 de junio de 2014, 20:04
 */

#ifndef VISTANIVEL_H
#define	VISTANIVEL_H
#include <gtkmm-3.0/gtkmm.h>
#include <vector>
#include <string>
#include "editor_Nivel.h"
using std::vector;
using std::string;

class VistaNivel {
public:
    VistaNivel();
    void run();
    void runLoadedLevel();
    void setWindowsBack(Gtk::Window *windowBack);
    void setLevel(Nivel* level);
    unsigned int getId();
    virtual ~VistaNivel();
private:
    void loadWidgets();
    void connectWidgets();
    void close();
    void back();
    void save();
    void reset();
    void buttonGroundPressed();
    void buttonMetalPressed();
    void buttonBoxPressed();
    void buttonBoxEnemyPressed();
    void buttonZombieRedPressed();
    void buttonZombieGreenPressed();
    void buttonZombieBluePressed();
    void buttonFriendPressed();
    void buttonPlayerPressed();
    void hideMessageError();
    void saveExit();
    void generateGridMap();
    void intersect(int x, int y);
    void transformateCoordenades(int x, int y, int& col, int& row);
    bool cleanCell(GdkEventButton* event);
    void createModel();
    void onComboSizeMapChanged();
    //Signal handlers:
    void on_button_drag_data_get(
            const Glib::RefPtr<Gdk::DragContext>& context,
            Gtk::SelectionData& selection_data, guint info, guint time);
    void on_label_drop_drag_data_received(
            const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
            const Gtk::SelectionData& selection_data, guint info, guint time);
    void highlightGrid(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
            const Gtk::SelectionData& selection_data, guint info, guint time);

    Nivel* level;
    Glib::RefPtr<Gtk::Builder> builder;
    Gtk::Window *window, *windowsBack;
    Gtk::Entry* entryName;
    Gtk::Button *buttonSave, *buttonBack, *buttonGenerate, *buttonReset;
    Gtk::Button *buttonZombieRed, *buttonZombieBlue, *buttonZombieGreen, *buttonFriend, *buttonPlayer;
    Gtk::Button *buttonGround, *buttonBox, *buttonMetal, *buttonBoxEnemy;
    Gtk::Button *buttonOk, *buttonOk2;
    //Gtk::SpinButton *spinWidth, *spinHeight;
    Gtk::Grid *grid;
    Gtk::Scrollbar *scrollVertical, *scrollHorizontal;
    vector<Gtk::TargetEntry> listTargets;
    Gtk::ComboBox *comboSizeMap;
    Gtk::MessageDialog *message,*messageError;
    string buttonPressed;
    bool gridOk;

    class ModelColumnsSizeMap : public Gtk::TreeModel::ColumnRecord {
    public:

        ModelColumnsSizeMap() {
            add(colSizeName);
        }
        Gtk::TreeModelColumn<Glib::ustring> colSizeName;
    };
    ModelColumnsSizeMap columnsSizeMap;
    Glib::RefPtr<Gtk::ListStore> refTreeModelSizeMap;
};

#endif	/* VISTANIVEL_H */

